//
//  TravelTactic_RegionTableViewCell.m
//  BTRIP
//
//  Created by Rain on 15/11/16.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "TravelTactic_RegionTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <SDWebImageManager.h>
#import "TravelTactic_RegionModel.h"

@interface TravelTactic_RegionTableViewCell ()

@property (nonatomic, retain) UIView *view;

@end

@implementation TravelTactic_RegionTableViewCell

- (void)dealloc {
    [_title release];
    [_name release];
    [_image_url release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.view = [[UIView alloc] init];
        self.view.layer.cornerRadius = 5 * SWIDTH;
        self.view.layer.masksToBounds = YES;
        [self.contentView addSubview:self.view];
        [self.view release];
        
        self.image_url = [[UIImageView alloc] init];
        self.image_url.layer.cornerRadius = 10 * SWIDTH;
        self.image_url.layer.masksToBounds = YES;
        [self.view addSubview:self.image_url];
        [self.image_url release];
        
        self.name = [[UILabel alloc] init];
        self.name.font = [UIFont systemFontOfSize:24];
        self.name.shadowColor = [UIColor grayColor];
        self.name.textColor = [UIColor whiteColor];
        [self.image_url addSubview:self.name];
        [self.name release];
        
        self.title = [[UILabel alloc] init];
        self.title.font = [UIFont systemFontOfSize:16];
        self.title.shadowColor = [UIColor grayColor];
        self.title.textColor = [UIColor whiteColor];
        [self.image_url addSubview:self.title];
        [self.title release];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.view.frame = CGRectMake(5 * SWIDTH, 5 * SWIDTH, self.frame.size.width - 10 * SWIDTH, self.frame.size.height - 10 * SWIDTH);
    self.image_url.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    self.name.frame = CGRectMake(10 * SWIDTH, 150 * SWIDTH, 200 * SWIDTH, 35 * SWIDTH);
    self.title.frame = CGRectMake(10 * SWIDTH, 180 * SWIDTH, 250 * SWIDTH, 25 * SWIDTH);
    
}

- (void)setRegionModel:(TravelTactic_RegionModel *)regionModel {
    
    if (_regionModel != regionModel) {
        [_regionModel release];
        _regionModel = [regionModel retain];
    }
    [self.image_url sd_setImageWithURL:[NSURL URLWithString:_regionModel.image_url] placeholderImage:[UIImage imageNamed:@"background"]];
    self.name.text = _regionModel.name;
    self.title.text = _regionModel.title;
   
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
